<template>
  <div>
    <el-row>
      <el-col :span="17" style="border-right: 3px solid #dcdfe6; padding-right: 5px">
        <withTable :tFId="tFId" :tableConfig="props.params" :userParams="{ methodId: props.methodId,nextUser: props.nextUser }" ref="withTableRef"
          :formulaParams="{
            methodId: props.methodId,
            tableId: props.params.tableId,
            lMId: lMId,
            isResult: 0
          }" />
      </el-col>
      <el-col :span="7" style="padding-left: 5px">
        <RightWrite v-if="props.params.userStepId == 0 && props.params.userStatus == 0" :projectId="props.projectId"
          :methodId="props.methodId" :params="props.params" :lMId="lMId" @changeDate="changeDate" @search="search">
        </RightWrite>
        <rightApprove v-else :params="props.params" :pId="pId"></rightApprove>
      </el-col>
    </el-row>
  </div>
</template>

<script setup>
import { nextTick } from "vue";
import withTable from "./withTable.vue";
import bus from "@/utils/eventBus";
import RightWrite from "../common/rightWrite.vue";
import rightApprove from "../common/rightApprove.vue";

const { proxy } = getCurrentInstance();
const tFId = ref("");
const props = defineProps({
  params: {
    type: Object,
    required: true,
  },
  lMId: {
    type: String,
  },
  pId: {
    type: String,
  },
  methodId: {
    type: String,
  },
  projectId: {
    type: String,
  },
  nextUser: {
    type: Object,
  },
});

nextTick(() => {
  tFId.value = props.params.tFId;
});

function changeDate() {
  bus.emit("submit" + tFId.value, { isAutoSave: true, isShowTable: true })
}

onBeforeUnmount(() => {
  bus.off("submit" + tFId.value);
  bus.off("submitData" + tFId.value);
});

const withTableRef = ref(null)

function search() {
  proxy.$refs['withTableRef'].showTable()
}
</script>
